home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Scripting 2882110132001.psc / modSEX_CommonFunctions.bas < prev    next >
Encoding:
BASIC Source File  |  2001-10-11  |  2.4 KB  |  72 lines

  1. Attribute VB_Name = "modSEX_CommonFunctions"
  2. Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
  3. Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
  4. Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
  5.  
  6. Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal mWnd As Long, ByVal aWnd As Long, data As String, parms As String, show As Boolean, nopause As Boolean) As Long
  7.  
  8. Function CallDLL(strLibraryName As String, functionName As String)
  9.     Dim lb As Long, pa As Long
  10.     'map 'user32' into the address space of the calling process.
  11.     lb = LoadLibrary(strLibraryName)
  12.     pa = GetProcAddress(lb, functionName)
  13.     'CallWindowProc pa, Me.hWnd,
  14.     
  15. End Function
  16.  
  17. Function FileExists(strFileName As String) As Boolean
  18.     On Error GoTo MakeF
  19.     'If file does Not exist, there will be an Error
  20.     Open strFileName For Input As #1
  21.     Close #1
  22.     'no error, file exists
  23.     FileExists = True
  24.     Exit Function
  25. MakeF:
  26.     'error, file does Not exist
  27.     FileExists = False
  28.     Exit Function
  29.  
  30. End Function
  31.  
  32.  
  33. Function JoinArray(thearray() As String, strDelim As String, start As Integer, Optional endx As Integer = -1) As String
  34.     If endx = -1 Then endx = UBound(thearray) + 1
  35.     Dim i As Integer, result As String
  36.     
  37.     For i = start - 1 To endx - 1
  38.         If i = endx - 1 Then
  39.             result = result & thearray(i)
  40.         Else
  41.             result = result & thearray(i) & strDelim
  42.         End If
  43.     Next i
  44.     JoinArray = result
  45. End Function
  46.  
  47. Function JoinArrayV(thearray(), strDelim As String, start As Integer, Optional endx As Integer = -1) As String
  48.     If endx = -1 Then endx = UBound(thearray) + 1
  49.     Dim i As Integer, result As String
  50.     
  51.     For i = start - 1 To endx - 1
  52.         If i = endx - 1 Then
  53.             result = result & thearray(i)
  54.         Else
  55.             result = result & thearray(i) & strDelim
  56.         End If
  57.     Next i
  58.     JoinArrayV = result
  59. End Function
  60.  
  61. Function TrimLeft(strText As String) As String
  62.     Dim i As Integer
  63.     For i = 1 To Len(strText)
  64.         If Mid(strText, i, 1) <> " " And Mid(strText, i, 1) <> Chr(9) Then
  65.             TrimLeft = Right(strText, Len(strText) - (i - 1))
  66.             Exit Function
  67.         End If
  68.     Next i
  69. End Function
  70.  
  71.  
  72.